<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!doctype html>
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>任务计划表</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<jsp:include page="/WEB-INF/views/common.jsp"></jsp:include>

  </head>
  
  <body class="easyui-layout">
  <input type="hidden" id="taskId" value="${taskId }" />
	    <table id="dg">	 </table>
  </body>
  
  <script type="text/javascript">
  $('#dg').datagrid({    
	    //title:"任务反馈列表",
		border:0,
		nowrap:true,
		striped:true,
		fit: true,//自动大小
		url:'taskPlan/queryTaskPlans',
		queryParams : {taskId : $('#taskId').val()},
		frozenColumns:[[    
	        {field : 'id', title : 'ID', hidden:true},    
	        {field : 'taskId', title : '任务ID', hidden:true},
	        {field : 'name', title : '名称', width:150,
	        	formatter : function (value, row, index) {
	        		if(row.isTimeout ==1){
	        			if(row.status ==0)
	        				return colorRow(value,"red");
	        			return colorRow(value,"blue");
	        		}
	        		return  value ;
					
	        	}
	        },{field : 'planActorName', title : '责任人', width:150,
	        	formatter : function (value, row, index) {
	        		if(row.isTimeout ==1){
	        			var _value = value||'';
	        			if(row.status ==0)
	        				return colorRow(_value,"red");
	        			return colorRow(_value,"blue");
	        		}
	        		return  value ;
					
	        	}}
	    ]],
	    columns : [[
			{field : 'endTime', title : '计划完成时间', width:150,
	        	formatter : function (value, row, index) {
	        		if(row.isTimeout ==1){
	        			if(row.status ==0)
	        				return colorRow(value,"red");
	        			return colorRow(value,"blue");
	        		}
	        		return  value ;
					
	        	}},
	        {field : 'finishTime', title : '实际完成时间', width:150,
		        	formatter : function (value, row, index) {
		        		var _value = value||'';
		        		if(row.isTimeout ==1){
		        			if(row.status ==0)
		        				return colorRow(_value,"red");
		        			return colorRow(_value,"blue");
		        		}
		        		return  _value ;
						
		        	}},
			{field : 'status', title : '实际完成情况', width:150,
				formatter : function (value, row, index) {
					var _value = value||'';
					if(value == 0){
						_value=  "未完成";
					}
					if(value == 1){
						_value=  "已完成";
					}
					if(row.isTimeout ==1){
	        			if(row.status ==0)
	        				return colorRow(_value,"red");
	        			return colorRow(_value,"blue");
	        		}
	        		return _value ;
	        	}
			},	
			{field : 'isTimeout', title : '超时状态', width:150,
				formatter : function (value, row, index) {
					var _value = value||'';
					if(_value == 1){
						_value= "超时";
					}else{
						_value= "正常";
					}
					if(row.isTimeout ==1){
	        			if(row.status ==0)
	        				return colorRow(_value,"red");
	        			return colorRow(_value,"blue");
	        		}
	        		return _value ;
	        	}
			},	
			{field : 'planAmount', title : '预算', width:150,
	        	formatter : function (value, row, index) {
	        		if(row.isTimeout ==1){
	        			if(row.status ==0)
	        				return colorRow(value,"red");
	        			return colorRow(value,"blue");
	        		}
	        		return  value ;
					
	        	}},
			{field : 'remark', title : '描述', width : 300,
		        	formatter : function (value, row, index) {
		        		if(row.isTimeout ==1){
		        			if(row.status ==0)
		        				return colorRow(value,"red");
		        			return colorRow(value,"blue");
		        		}
		        		return  value ;
						
		        	}},
			{field : 'expectResult', title : '预期成果', width : 300,
			        	formatter : function (value, row, index) {
			        		if(row.isTimeout ==1){
			        			if(row.status ==0)
			        				return colorRow(value,"red");
			        			return colorRow(value,"blue");
			        		}
			        		return  value ;
							
			        	}}
      ]],
		singleSelect:true,
		rownumbers:true,
		toolbar:'#tb',
		pagination:true,
		pageSize:20,
		onClickRow:function(rowIndex, rowData){}/*,
		onLoadSuccess:function(data){
			if (data.total == 0) {
              //添加一个新数据行，第一列的值为你需要的提示信息，然后将其他列合并到第一列来，注意修改colspan参数为你columns配置的总列数
              $(this).datagrid('appendRow', { file_name: '<div style="text-align:center;color:red">没有相关记录！</div>' }).datagrid('mergeCells', { index: 0, field: 'file_name', colspan: 3 })
              //隐藏分页导航条，这个需要熟悉datagrid的html结构，直接用jquery操作DOM对象，easyui datagrid没有提供相关方法隐藏导航条
              $(this).closest('div.datagrid-wrap').find('div.datagrid-pager').hide();
          } else {
          	 //如果通过调用reload方法重新加载数据有数据时显示出分页导航容器
          	$(this).closest('div.datagrid-wrap').find('div.datagrid-pager').show();
          }
		}*/
	}).datagrid('getPager').pagination({  
      pageSize: 20,//每页显示的记录条数，默认为10  
      pageList: [20,50,100],//可以设置每页记录条数的列表  
      beforePageText: '第',//页数文本框前显示的汉字  
      afterPageText: '页    共 {pages} 页',  
      displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录'
  });
  
  function colorRow(value,color){
		if(value == null || value =='') return value;
		return "<font color='"+color+"'>"+ value + "</font>";
	}
  </script>
</html>